//
//  CDNavigationViewController.swift
//  chendong微博
//
//  Created by chen dong on 2021/3/16.
//

import UIKit

class CDNavigationViewController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()

        navigationBar.isHidden = false
        
        
    }
    
    /// 重写Push方法
    /// - Parameters:
    ///   - viewController: <#viewController description#>
    ///   - animated: <#animated description#>
    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        if viewControllers.count > 0 {
            //隐藏底部的tabbar
            viewController.hidesBottomBarWhenPushed = true
            
        }
        //判断控制器类型
        if let vc = viewController as? CDBaseViewController {
            vc.navItem.leftBarButtonItem = UIBarButtonItem(title:"返回", target: self, action: #selector(popToParent))
            
        }
        super.pushViewController(viewController, animated: true)
        
        
    }
    @objc private func popToParent () {
        popViewController(animated: true)
    }
    
    

}
